from django.db import models

from question.models import Questionnaire
from users.models import Account


class Wallet(models.Model):
    user = models.OneToOneField(to=Account, on_delete=models.CASCADE, verbose_name="所属用户")
    deposit = models.CharField(max_length=9, verbose_name="存款")


class Order(models.Model):
    STATUS = ((1, "正在进行"), (2, "已完成"), (3, "未完成"), (4, "被甄别"))
    user = models.ForeignKey(to=Account, on_delete=models.DO_NOTHING, verbose_name="顾客")
    user_name = models.CharField(max_length=50, verbose_name="顾客姓名")
    introducer = models.ForeignKey(to=Account, blank=True, on_delete=models.DO_NOTHING, related_name="introducer_user", verbose_name="介绍人")
    introducer_name = models.CharField(max_length=50, blank=True, verbose_name="介绍人姓名")
    product = models.ForeignKey(to=Questionnaire, on_delete=models.DO_NOTHING, verbose_name="购买商品")
    product_name = models.CharField(max_length=50, verbose_name="商品名称")
    price = models.CharField(max_length=9, verbose_name="单价")
    amount = models.PositiveIntegerField(verbose_name="数量")
    create_at = models.DateTimeField(auto_now_add=True, verbose_name="订单创建时间")
    finish_at = models.DateTimeField(verbose_name="完成时间")
    result = models.PositiveSmallIntegerField(choices=STATUS, verbose_name="订单处理结果")
